﻿
@model BBICMS.Application.InputModels.LanguageIM

@{
    ViewBag.Title = "添加" + EntityNames.Language;
    ViewBag.PageTitle = ViewBag.Title + "_组件";
   
}
@section Header{
   <link href="~/plugins/SigFinder/SigFinder.min.css" rel="stylesheet" />
    <link href="~/plugins/webuploader/webuploader.css" rel="stylesheet" />
   
}




<div class="panel panel-default">
    <header class="panel-heading">
        <span class="glyphicon glyphicon-edit"></span> @ViewBag.Title

    </header>

    <section class="panel-body">

        @using (Ajax.BeginForm("Add", null, new AjaxOptions()
        {          
            LoadingElementId = "saving",
            LoadingElementDuration = 2000,
            //   Confirm = "Are you sure you want to save this User?"
            OnSuccess = "updateSuccess"

        }, new { @class = "form-horizontal", role = "form" }))
            {

            @Html.AntiForgeryToken()
            @Html.ValidationSummary(true)

            <div class="form-group">
                @Html.LabelFor(model => model.FullName, new { @class = "col-md-2 control-label" })
                <div class="col-md-5">
                    @Html.TextBoxFor(model => model.FullName, new { @class = "form-control", placeholder = ModelMetadata.FromLambdaExpression(x => x.FullName, ViewData).Watermark })
                    @Html.ValidationMessageFor(model => model.FullName)
                </div>
           </div>

            <div class="form-group">
                @Html.LabelFor(model => model.CultureName, new { @class = "col-md-2 control-label" })
                <div class="col-md-5">
                    @Html.TextBoxFor(model => model.CultureName, new { @class = "form-control", placeholder = ModelMetadata.FromLambdaExpression(x => x.CultureName, ViewData).Watermark })
                    @Html.ValidationMessageFor(model => model.CultureName)
                </div>
            </div>

                <div class="form-group">
                    @Html.LabelFor(model => model.Icon, new { @class = "col-md-2 control-label" })
                    <div class="col-md-5">
                        <div class="input-group">
                            @Html.TextBoxFor(model => model.Icon, new { @class = "form-control", placeholder = "图标" })
                            <span class="input-group-btn">
                                <button class="btn btn-default" id="btnThumbnail" type="button">浏览…</button>
                            </span>
                        </div><!-- /input-group -->
                    </div>
                    <div class="col-md-5">
                        @Html.ValidationMessageFor(model => model.Icon)
                    </div>
                </div>

                <div class="form-group">
                    @Html.LabelFor(model => model.Importance, new { @class = "col-md-2 control-label" })
                    <div class="col-md-5">
                        @Html.TextBoxFor(model => model.Importance, new { @class = "form-control", type = "number", placeholder = "排序" })
                    </div>
                    <div class="col-md-5">
                        @Html.ValidationMessageFor(model => model.Importance)
                    </div>

                </div>

                <div class="form-group">
                    <div class="col-md-10 col-md-offset-2">
                        <div class="checkbox">
                            <label>
                                @Html.CheckBoxFor(model => model.IsDefault)  @Html.DisplayNameFor(model => model.IsDefault)  @Html.ValidationMessageFor(model => model.IsDefault)
                            </label>
                        </div>
                    </div>
                </div>


                <div class="form-group">
                    <div class="col-md-10 col-md-offset-2">
                        <div class="checkbox">
                            <label>
                                @Html.CheckBoxFor(model => model.Active)  @Html.DisplayNameFor(model => model.Active)  @Html.ValidationMessageFor(model => model.Active)
                            </label>
                        </div>
                    </div>
                </div>

                <div class="form-group">
                    <div class="col-sm-offset-2 col-md-10">
                        <input type="submit" class="btn btn-primary" value="@Buttons.Add" /> <a href="@Url.Action("Index")" class="btn btn-default">@Buttons.Back</a>
                    </div>
                </div>

        }

    </section>
</div>

@Html.Action("PopuFinder","File")


@section Footer {
    @Scripts.Render("~/bundles/jqueryvalWithBootstrap")
<script src="/Plugins/webuploader/webuploader.min.js"></script>
<script src="/Plugins/SigFinder/FileManager.js"></script>

    <script>

      

        function SetThumbnail() {
            var fileUrl = $("#fileList .item.active").attr("data-file");
            $('#Icon').val(fileUrl);
            $('#fileManagerModal').modal('hide');
        }


    function updateSuccess(data) {

        @*//  console.log(data.Oicq);
        toastr.options = {
            "positionClass": "toast-bottom-full-width"
        }
        if (data) {
            toastr.success('新闻已添加成功！', '@ViewBag.Title')
        } else {
            toastr.error('新闻添加失败！', '@ViewBag.Title')
        }*@

        var title = '@ViewBag.Title';
        Common.ShowBox(data.Status, data.Message, title);

    }



    $(function () {
        $("#btnThumbnail").on("click", function () {
            $('#fileManagerModal').modal();
            $("#selectImage").unbind('click');
            $("#selectImage").bind("click", function () {
                SetThumbnail();
            });
        });
        
        });
    </script>
}
